package com.scetop.bank;

import java.util.ArrayList;
import java.util.List;

public class Customer {
    private String firstName;
    private String lastName;
    private List<Account> accounts;

    public Customer(String f, String l) {
        this.firstName = f;
        this.lastName = l;
        this.accounts = new ArrayList<>();
    }

    public String getFirstName() {
        return firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void addAccount(Account acct) {
        accounts.add(acct);
    }

    public Account getAccount(int index) {
        if (index < 0 || index >= accounts.size()) {
            return null;
        }
        return accounts.get(index);
    }

    public Account getAccount() {
        if (accounts.isEmpty()) {
            return null;
        }
        return accounts.get(0);
    }

    public void setAccount(Account account) {
        this.accounts.clear();
        this.accounts.add(account);
    }

    public int getNumOfAccounts() {
        return accounts.size();
    }
}